const Router = require('@koa/router')
const model = require("../app/models")
const resData = require('../utils/response')

const menu = model.menu
const router = new Router()
router.post('/add', async (ctx) => {
    try {
        await menu.create({ ...ctx.request.body })
        ctx.body = resData(200, '成功')
    } catch (error) {
        ctx.body = resData(-12000, '新增失败,' + error)
    }
})
router.get('/list', async (ctx) => {
    try {
        var result = await menu.findAll();
        ctx.body = resData(200, '成功', result)
    } catch (error) {
        ctx.body = resData(-15000, '查询失败,' + error)
    }
})
router.get('/deleate', async (ctx) => {

})
module.exports = router;